_flavor="postmarketos-qcom-sm8150-nabu"
pkgname=linux-$_flavor
pkgver=6.12.0
pkgrel=0
pkgdesc="Mainline Kernel fork for SM8150 devices"
arch="aarch64"
_carch="arm64"
url="https://gitlab.postmarketos.org/panpanpanpan/sm8150-mainline"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-nftables
	"
makedepends="
	postmarketos-installkernel
	bash
	bison
	findutils
	flex
	installkernel
	openssl-dev
	perl
	python3
	"

_repo="sm8150-mainline"
_config="config-$_flavor.$arch"
_commit="c4e7de505964a69e2757523fd25343a2bf832b98"

# Source
source="
	$_repo-$_commit.tar.gz::https://gitlab.postmarketos.org/panpanpanpan/sm8150-mainline/-/archive/$_commit/$_repo.tar.gz
	$_config
"
builddir="$srcdir/$_repo-$_commit"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .config
}

build()	{
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel+ 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot

	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot/ \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
6f1ffea0322415b3e6a0176ad6a16a4accb7c611581ffc2bb772ddfdc04af677a5b5f955d19b29f7baf1c6a9b7297273f55c818cec981b2b8960c781dbb8bb56  sm8150-mainline-c4e7de505964a69e2757523fd25343a2bf832b98.tar.gz
b94e0227abf1eb2fa016f2fcae935c4357fe2a61d3c0ff8131ffb45eea0be49836b8447106e4c343d081341eebe86f578566b624d92df2986dda3674d19c9ee7  config-postmarketos-qcom-sm8150-nabu.aarch64
"
